Public Class frmItemSearchPOS
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents dgProduct As System.Windows.Forms.DataGrid
    Friend WithEvents tbBarCode As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents cmdExit As DevComponents.DotNetBar.ButtonX
    Friend WithEvents GroupPanel1 As DevComponents.DotNetBar.Controls.GroupPanel
    Friend WithEvents tbDays As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.dgProduct = New System.Windows.Forms.DataGrid()
        Me.tbBarCode = New System.Windows.Forms.TextBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.tbDays = New System.Windows.Forms.TextBox()
        Me.cmdExit = New DevComponents.DotNetBar.ButtonX()
        Me.GroupPanel1 = New DevComponents.DotNetBar.Controls.GroupPanel()
        CType(Me.dgProduct, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupPanel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'dgProduct
        '
        Me.dgProduct.BackColor = System.Drawing.Color.White
        Me.dgProduct.BackgroundColor = System.Drawing.Color.AliceBlue
        Me.dgProduct.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgProduct.CaptionVisible = False
        Me.dgProduct.DataMember = ""
        Me.dgProduct.HeaderBackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(128, Byte), Integer))
        Me.dgProduct.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgProduct.Location = New System.Drawing.Point(15, 90)
        Me.dgProduct.Name = "dgProduct"
        Me.dgProduct.ReadOnly = True
        Me.dgProduct.Size = New System.Drawing.Size(492, 214)
        Me.dgProduct.TabIndex = 3
        '
        'tbBarCode
        '
        Me.tbBarCode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbBarCode.Location = New System.Drawing.Point(15, 58)
        Me.tbBarCode.Multiline = True
        Me.tbBarCode.Name = "tbBarCode"
        Me.tbBarCode.Size = New System.Drawing.Size(181, 26)
        Me.tbBarCode.TabIndex = 1
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label1.Location = New System.Drawing.Point(14, 13)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(117, 18)
        Me.Label1.TabIndex = 50
        Me.Label1.Text = "Barcode to search"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.BackColor = System.Drawing.Color.Transparent
        Me.Label2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label2.Location = New System.Drawing.Point(196, 14)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(102, 18)
        Me.Label2.TabIndex = 52
        Me.Label2.Text = "Days to include"
        '
        'tbDays
        '
        Me.tbDays.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbDays.Location = New System.Drawing.Point(202, 58)
        Me.tbDays.Multiline = True
        Me.tbDays.Name = "tbDays"
        Me.tbDays.Size = New System.Drawing.Size(99, 26)
        Me.tbDays.TabIndex = 2
        Me.tbDays.Text = "14"
        Me.tbDays.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'cmdExit
        '
        Me.cmdExit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdExit.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdExit.Location = New System.Drawing.Point(432, 317)
        Me.cmdExit.Name = "cmdExit"
        Me.cmdExit.Size = New System.Drawing.Size(75, 28)
        Me.cmdExit.TabIndex = 53
        Me.cmdExit.Text = "Exit"
        '
        'GroupPanel1
        '
        Me.GroupPanel1.CanvasColor = System.Drawing.SystemColors.Control
        Me.GroupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007
        Me.GroupPanel1.Controls.Add(Me.Label2)
        Me.GroupPanel1.Controls.Add(Me.Label1)
        Me.GroupPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupPanel1.Location = New System.Drawing.Point(0, 0)
        Me.GroupPanel1.Name = "GroupPanel1"
        Me.GroupPanel1.Size = New System.Drawing.Size(524, 358)
        '
        '
        '
        Me.GroupPanel1.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2
        Me.GroupPanel1.Style.BackColorGradientAngle = 90
        Me.GroupPanel1.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground
        Me.GroupPanel1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderBottomWidth = 1
        Me.GroupPanel1.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        Me.GroupPanel1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderLeftWidth = 1
        Me.GroupPanel1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderRightWidth = 1
        Me.GroupPanel1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderTopWidth = 1
        Me.GroupPanel1.Style.CornerDiameter = 4
        Me.GroupPanel1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded
        Me.GroupPanel1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center
        Me.GroupPanel1.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText
        Me.GroupPanel1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near
        Me.GroupPanel1.TabIndex = 54
        Me.GroupPanel1.Text = "Product Search - POS"
        '
        'ICprodInvSearch
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.Color.LightSteelBlue
        Me.ClientSize = New System.Drawing.Size(524, 358)
        Me.ControlBox = False
        Me.Controls.Add(Me.cmdExit)
        Me.Controls.Add(Me.tbDays)
        Me.Controls.Add(Me.tbBarCode)
        Me.Controls.Add(Me.dgProduct)
        Me.Controls.Add(Me.GroupPanel1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Location = New System.Drawing.Point(30, 70)
        Me.Name = "ICprodInvSearch"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        CType(Me.dgProduct, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupPanel1.ResumeLayout(False)
        Me.GroupPanel1.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region

    Private Sub ICsavedInvSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    Private Sub dgformat(ByVal RowCount As Integer)
        Dim grdTableStyle As New DataGridTableStyle
        With grdTableStyle
            .AlternatingBackColor = Color.AliceBlue
            .HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold)
            .MappingName = "INVOICE"
            .PreferredColumnWidth = 160
            .HeaderBackColor = Color.LightSlateGray
            .HeaderForeColor = Color.LightCyan
            .PreferredRowHeight = 15
            .RowHeadersVisible = False
            .RowHeaderWidth = 0
        End With
        Dim cs1 As DataGridColumnStyle
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 70
        cs1.MappingName = "INVNO"
        cs1.HeaderText = "INV.NO."
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 95
        cs1.MappingName = "INVDATETIME"
        cs1.HeaderText = "INV.DATE"
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 100
        cs1.MappingName = "DEPARTMENTNAME"
        cs1.HeaderText = "SHOWROOM"
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 65
        cs1.MappingName = "INVQTY"
        cs1.HeaderText = "QTY"
        cs1.NullText = ""
        cs1.ReadOnly = True
        cs1.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 65
        cs1.MappingName = "INVPRICE"
        cs1.HeaderText = "U.PRICE"
        cs1.NullText = ""
        cs1.ReadOnly = True
        cs1.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 65
        cs1.MappingName = "INVDISA"
        cs1.HeaderText = "DIS.AMT"
        cs1.NullText = ""
        cs1.ReadOnly = True
        cs1.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 65
        cs1.MappingName = "CASHSETTLE"
        cs1.HeaderText = "CASH"
        cs1.NullText = ""
        cs1.ReadOnly = True
        cs1.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 65
        cs1.MappingName = "INVCRAMT"
        cs1.HeaderText = "CREDIT"
        cs1.NullText = ""
        cs1.ReadOnly = True
        cs1.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        dgProduct.TableStyles.Add(grdTableStyle)
    End Sub
    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Me.Close()
    End Sub

    Private Sub dgProduct_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgProduct.MouseUp
        Dim pt As New Point(e.X, e.Y)
        Dim hti As DataGrid.HitTestInfo = dgProduct.HitTest(pt)
        If hti.Type = DataGrid.HitTestType.Cell Then
            dgProduct.CurrentCell = New DataGridCell(hti.Row, hti.Column)
            dgProduct.Select(hti.Row)
        End If
    End Sub

    Private Sub ShowData()
        If IsNumeric(tbDays.Text) Then
            Dim ICdata As New ICdataLogic
            Dim ds As DataSet
            ds = ICdata.GetProdInvoiceData(tbBarCode.Text, tbDays.Text)
            dgProduct.DataSource = ds.Tables(0)
            With dgProduct
                ' .BackgroundColor = GridBackgroundColor
                .TableStyles.Clear()
                .CaptionBackColor = System.Drawing.Color.SlateBlue
                .CaptionForeColor = System.Drawing.Color.LemonChiffon
                .AllowSorting = True
                .AlternatingBackColor = System.Drawing.Color.AliceBlue
                .ParentRowsBackColor = System.Drawing.Color.Lavender
                .ParentRowsForeColor = System.Drawing.Color.SlateBlue
                .HeaderBackColor = System.Drawing.Color.LemonChiffon
                .AllowNavigation = False
                .ParentRowsVisible = False
                .RowHeadersVisible = False
            End With

            Dim cm As CurrencyManager = BindingContext(dgProduct.DataSource, dgProduct.DataMember)
            Dim dv As DataView = cm.List
            dv.AllowNew = False
            dgformat(ds.Tables(0).Rows.Count)
            If ds.Tables(0).Rows.Count > 0 Then
                dgProduct.Select(dgProduct.CurrentRowIndex())
            End If
            ICdata = Nothing
        Else
            MsgBox("Days to include should be Numeric!", MsgBoxStyle.Information, "Inventory Manager")
        End If
    End Sub

    Private Sub tbBarCode_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbBarCode.Validated
        If tbBarCode.Text.Trim <> "" And tbDays.Text.Trim <> "" Then
            ShowData()
        End If
    End Sub
    Private Sub tbDays_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbDays.Validated
        If tbBarCode.Text.Trim <> "" And tbDays.Text.Trim <> "" Then
            ShowData()
        End If
    End Sub
    Private Sub tbBarCode_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbBarCode.KeyUp
        If e.KeyCode = Keys.Enter Then
            SendKeys.Send("{Tab}")
        End If
    End Sub
    Private Sub tbDays_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbDays.KeyUp
        If e.KeyCode = Keys.Enter Then
            SendKeys.Send("{Tab}")
        End If
    End Sub
End Class
